﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Publishing.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint.WebPartPages;

namespace SlightlyEnhancedContentByQueryWebPartSolution
{
    public abstract class EditorPartHelper
    {

        public static HtmlGenericControl createConfigureSectionControls(ToolPart toolPart, string expandToolTip, string collapseToolTip, string displayText, string id, string helpTopic,out Table sectionTable )
        {
            HtmlGenericControl configureSection = CmsDataFormWebPart.CreateToolPartToggleSwitch(toolPart, expandToolTip, collapseToolTip, displayText, id, helpTopic );
            sectionTable = new Table();
            sectionTable.CellPadding = 0;
            sectionTable.CellSpacing = 0;
            sectionTable.Style["border-collapse"] = "collapse";
            sectionTable.Attributes.Add("width", "100%");            
            configureSection.Controls.Add(sectionTable);
            return configureSection;
        }

        public static void addToolPaneControl(Table sectionTable, string label, Control newControl)
        {
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            cell.Controls.Add(new LiteralControl("<div class=\"UserSectionHead\">"));
            Label child = new Label();
            child.Text = SPHttpUtility.HtmlEncode(label);
            cell.Controls.Add(new LiteralControl("<b>"));
            cell.Controls.Add(child);
            cell.Controls.Add(new LiteralControl(":"));
            cell.Controls.Add(new LiteralControl("</b>"));
            cell.Controls.Add(new LiteralControl("</div>"));
            cell.Controls.Add(new LiteralControl("<div class=\"UserSectionBody\"><div class=\"UserControlGroup\"><nobr>"));
            cell.Controls.Add(newControl);
            cell.Controls.Add(new LiteralControl("</nobr></div></div>"));
            cell.Controls.Add(new LiteralControl("<div style='width:100%' class='UserDottedLine'></div>"));
            row.Cells.Add(cell);
            sectionTable.Rows.Add(row);
        }
    }
}
